<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>call原理</title>
</head>
<body>
<script>
    function fn() {
        //伪数组转换成真数组
//        let arr = [].slice.call(arguments);
        //节省性能
        let arr = Array.prototype.slice.call(arguments);
    }

//    [].slice === Array.prototype.slice

    console.log(Array.prototype.slice); // ƒ slice() { [native code] }

    Array.prototype.slice = function (arg) {
        console.log("我是改写后的slice的this", this);


        console.log("我是改写后的slice的arg", arg);

        return this
    };

    let arr = [1,2,3,4];
//    arr.slice("text01");

    arr.slice.call({a:1},"text02")



























/*
    console.log(Array.prototype.slice); //function slice(){...}
    Array.prototype.slice = function (param) {
        console.log("我是重写slice后的this",this);
        console.log("我是重写slice后的param",param);
        let that = this;
        return that;
    };

    let arr = [1,2,3,4];
    arr.slice("testText");
    // "我是重写slice后的this", [1,2,3,4]
    // "我是重写slice后的param", "testText"
    arr.slice.call({"a":1},"callText")*/
    
</script>
</body>
</html>